﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using VOL.Domain.IServices.WarehouseManagement;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers.WarehouseManagement
{
    /// <summary>
    /// 外协入库
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class OutsourcingWarehousingController : ControllerBase
    {
        private readonly IOutsourcingWarehousingServices _outsourcingWarehousingServices;

        public OutsourcingWarehousingController(IOutsourcingWarehousingServices outsourcingWarehousingServices)
        {
            _outsourcingWarehousingServices = outsourcingWarehousingServices;
        }

        /// <summary>
        /// 外协入库新增
        /// </summary>
        /// <param name="outsourcingWarehousing"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddOutsourcingWarehousing([FromBody]OutsourcingWarehousing outsourcingWarehousing)
        {
            return await _outsourcingWarehousingServices.AddOutsourcingWarehousing(outsourcingWarehousing);
        }
        /// <summary>
        /// 外协入库删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<int> DeleteOutsourcingWarehousing(int id)
        {
           return await _outsourcingWarehousingServices.DeleteOutsourcingWarehousing(id);
        }
        /// <summary>
        /// 外协入库显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<OutsourcingWarehousing>> GetAllOutsourcingWarehousing(string? stockroomCode, string? outsourcing, string? supplierName, int pageIndex = 1, int pageSize = 5)
        {
            return await _outsourcingWarehousingServices.GetAllOutsourcingWarehousing(stockroomCode, outsourcing, supplierName, pageIndex, pageSize);
        }
        /// <summary>
        /// 外协入库修改
        /// </summary>
        /// <param name="outsourcingWarehousing"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateOutsourcingWarehousing([FromBody]OutsourcingWarehousing outsourcingWarehousing)
        {
            return await _outsourcingWarehousingServices.UpdateOutsourcingWarehousing(outsourcingWarehousing);
        }
    }
}
